home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / cycles / cycles.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.1 KB  |  178 lines

  1.  
  2. #include <gl/gl.h>
  3.  
  4. #define DIM 200.0        /* size of playing field */
  5. #define TRAIL_HEIGHT 3.0    /* height of trails  */
  6. #define TRAIL_LENGTH 50     /* only remembers last TRAIL_LENGTH trail sections
  7.                                (MAX 128 'cos of drawing) */
  8. #define NAME_SIZE 16        /* max size of persons name */
  9. #define GRAVITY 1.0        /* acceleration of gravity */
  10. #define JUMP_POWER 5.0        /* how fast you take off */
  11. #define HEIGHT 5.0        /* cycle height */
  12. #define WALL_FALL 25        /* number of units it takes for an exploded
  13.                                cycle's trail to drop */
  14. #define TUMBLE_HEIGHT 100   /* height that drop onto grid from */
  15. #define IN_TUMBLE 30        /* time to drop onto grid */
  16. #define CYCLES 20        /* Total max number of players (including us) */
  17. #define REAL_SPEED 10.0        /* arbitrary speed ratio between frame
  18.                                updates, real time and speed of cycles
  19.                    ie. the frame rate at which the cycle
  20.                    speeds need no adjustment */
  21. #define MIN_STEP 1.0        /* allowable cycle steps */
  22. #define MAX_STEP 10.0
  23.  
  24. #define CYCLE_WIDTH 0.7        /* cycle width */
  25. #define CYCLE_LENGTH 8.0    /* length of bike */
  26. #define CYCLE_VIEW_PT 5.0   /* pos on the cycle we look from (measured from rear) */
  27. #define CYCLE_TAIL CYCLE_VIEW_PT
  28. #define CYCLE_NOSE (CYCLE_LENGTH - CYCLE_TAIL)
  29.  
  30. #define NET_TIMEOUT 5        /* seconds before we've lost the network */
  31. #define LEVELS 3        /* number of different playing grids */
  32. #define HOLE_SIZE 10.0        /* size of teleport holes (0.05*DIM) */
  33.  
  34.  
  35. /* debugging, timing, shading etc flags */
  36. #define no_SHOW_TIMING
  37. #define RGB_MODE
  38. #define no_DEBUG
  39.  
  40. #ifdef RGB_MODE
  41. #   define SHADING
  42. #else
  43. #   define no_SHADING
  44. #endif
  45.  
  46.  
  47. /* indexes into trail colour array */
  48. #define COLOURS 6
  49. #define TRAIL0 0
  50. #define TRAIL1 1
  51. #define TRAIL2 2
  52. #define TRAIL3 3
  53. #define TRAIL4 4
  54. #define TRAIL5 5
  55.  
  56. #ifdef RGB_MODE
  57. #define GREY25 0x191919
  58. #define GREY50 0x323232
  59. #else
  60. #define GREY25 100
  61. #define GREY50 101
  62. #endif
  63.  
  64.  
  65. typedef struct {
  66.     Coord x,y,z;
  67.     short level;
  68. } POINT;
  69.  
  70. /*
  71.  * CYCLE STRUCTURE:
  72.  *  direction: where the cycle is facing
  73.  *  view: used in 'lookat' statement (what is cycle lookint towards)
  74.  *  origin: where is cycle
  75.  *  trail: last TRAIL_LENGTH turning points of cycle
  76.  *  step: speed of cycle
  77.  *  jump_speed: vertical speed of cycle during jump
  78.  *  trail_ptr: how many trail points have been used
  79.  *  jump: flag for determining whether cycle is jumping or not
  80.  *  fall: index for counting the fall of a wall at cycle death
  81.  *        and for counting the initial fall down onto the grid
  82.  *  falling: is the same as a fall, just it's an integer
  83.  *  trail_colour: colour of trail
  84.  *  lturn,rturn: flags to tell if a left or right turn has been recorded
  85.  *  vec_ptr: pointer to direction vector
  86.  *  alive: flag for aliveness
  87.  *  id: unique network id for this cycle (between 0 and CYCLES-1)
  88.  * 
  89.  * NOTE: all networked information must come before the trail[] data,
  90.  *       as this (and all data after it) are not always sent.
  91.  */
  92.  
  93. typedef struct {
  94.     /* networked data */
  95.     POINT direction, origin;
  96.     int trail_ptr, jump, trail_colour, alive, falling;
  97.     int quit, id, vec_ptr, level, who_we_hit;
  98.     float fall, step;
  99.     POINT trail_update;
  100.     /* sometimes networked data */
  101.     POINT trail[TRAIL_LENGTH];
  102.     char name[NAME_SIZE];
  103.     /* local data */
  104.     POINT view;
  105.     float jump_speed;
  106.     int lturn, rturn, behave, type, owner, pts, games;
  107. } CYCLE;
  108.  
  109. /* for use in the mcast routines */
  110. #define SHORT_PACKET (3*sizeof(POINT) + 10*sizeof(int) + 2*sizeof(float))
  111. #define FULL_PACKET  sizeof(CYCLE)
  112. #define PERSON 0
  113. #define ROBOT  1
  114.  
  115. #define ABS(x)    ((x)<0.0?-(x):(x))
  116.  
  117. /*
  118.  * prototypes
  119.  */
  120. #ifdef SHOW_TIMING
  121. void show_time(double, float);
  122. #endif
  123.  
  124. /* externally used mcast stuff */
  125. int get_and_sort_mcasts(void);
  126. void send_all_full_mcast(void);
  127. void send_full_mcast(CYCLE *);
  128. void send_update_mcast(void);
  129. void init_network(int *);
  130. void init_comms(void);
  131. void parse_args(int, char **);
  132. int wait_for_replies(void);
  133. void kill_dead_cycle(void);
  134.  
  135. /* screen stuff */
  136. void score_screen(int, int, int);
  137. void title_screen(int, char *, int *, int *);
  138. void init_fonts(void);
  139. void scale_fonts_to_win(void);
  140.  
  141. /* the rest... */
  142. void do_scoring(CYCLE *, int *, int *, int *);
  143. void draw_coloured_grid(int );
  144. void init_holes(void);
  145. int fall_down_hole(CYCLE *);
  146. void new_level(CYCLE *, int );
  147. void draw_cute_flag(int );
  148. void write_player_list(float, float,  float);
  149. void move_our_robots(void);
  150. void draw_all_2d(void);
  151. void check_outside(CYCLE *);
  152. void draw_cycle(int, float, int, int, int, int);
  153. void draw_wheel(int);
  154. void set_win_coords(void);
  155. void search_for_exit(void);
  156. void init_tumble(CYCLE *);
  157. void tumble_down(CYCLE *);
  158. void draw_info(int, int, float, int, int, int);
  159. void set_speed_fac(int);
  160. void explode_me(CYCLE *);
  161. void drawgrid(int, int);
  162. void make_objs(void);
  163. void init_pos(CYCLE *);
  164. POINT vadd (POINT, POINT);
  165. void drawtrail(CYCLE *, int);
  166. void drawcycle(CYCLE *, int, int);
  167. void calcorg(CYCLE *);
  168. void explode(CYCLE *, int);
  169. void openwindow(void);
  170. void instructions(void);
  171. void newtrail(CYCLE *C);
  172. void turn(CYCLE *, float); 
  173. void jump(CYCLE *);
  174. void mov(CYCLE *);
  175. float block(int, float, float, int, int *);
  176. void move_cycles(CYCLE *);
  177. int main(int, char **);
  178.